package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicClerkDAO;
import com.cssy.xxkj.basic.entity.BasicClerkDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-10
 */
public class BasicClerkDAOImpl extends SqlMapClientDaoSupport implements BasicClerkDAO {

    /**
     * 插入数据
     * @param basicClerkDO
     * @return 插入数据的主键
     */
    public String insertBasicClerkDO(BasicClerkDO basicClerkDO) throws DataAccessException{
        Object id = getSqlMapClientTemplate().insert("BasicClerk.insert", basicClerkDO);
        return (String)id;
    }

    /**
     * 统计记录数
     * @param basicClerkDO
     * @return 查出的记录数
     */
    public Integer countBasicClerkDOByExample(BasicClerkDO basicClerkDO) throws DataAccessException{
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicClerk.countByDOExample", basicClerkDO);
        return count;
    }
    
    @Override
	public Integer updateBasicClerkDO(BasicClerkDO basicClerkDO)
			throws DataAccessException {
    	 int result = getSqlMapClientTemplate().update("BasicClerk.update", basicClerkDO);
         return result;
	}

    /**
     * 获取对象列表
     * @param basicClerkDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicClerkDO> findListByExample(BasicClerkDO basicClerkDO) throws DataAccessException{
        List<BasicClerkDO> list = getSqlMapClientTemplate().queryForList("BasicClerk.findListByDO", basicClerkDO);
        return list;
    }
    
    @Override
	public BasicClerkDO findBasicClerkDOByPrimaryKey(String id)
			throws DataAccessException {
    	BasicClerkDO basicClerkDO = (BasicClerkDO) getSqlMapClientTemplate().queryForObject("BasicClerk.findByPrimaryKey", id);
	    return basicClerkDO;
	}
    
    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicClerkDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicClerk.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicClerkDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicClerkDO> list = getSqlMapClientTemplate().queryForList("BasicClerk_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicClerk_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		int result = (Integer)getSqlMapClientTemplate().queryForObject("BasicClerk_ex.deleteBizRemoved", id);
        return result;
	}

}